package org.design.adapterPattern;

/**
 * MediaAdapter
 *
 * @author 樊温军
 * @date 2025/6/17 上午8:53
 */
public class MediaAdapter implements MediaPlayer {

    AdvancedMediaPlayer advancedMusicPlayer;

    public MediaAdapter(String fileName) {
        if (fileName.endsWith(".vlc")) {
            advancedMusicPlayer = new VlcPlayer();
        } else if (fileName.endsWith(".mp4")) {
            advancedMusicPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String fileName) {
        if (fileName.endsWith(".vlc")) {
            advancedMusicPlayer.playVlc(fileName);
        } else if (fileName.endsWith(".mp4")) {
            advancedMusicPlayer.playMp4(fileName);
        }
    }
}
